/*
 * Texture.h
 *
 *  Created on: 2009/01/14
 *      Author: Yongshik Cho
 */

#ifndef TEXTURE_H_
#define TEXTURE_H_

#include <vector>

#ifndef PREREQUISITES_H_
#	include "core/Prerequisites.h"
#endif

#ifndef ISMARTPTR_H_
#	include "core/ISmartPtr.h"
#endif

#ifndef VECTOR2D_H
#	include "core/Vector2D.h"
#endif

#ifndef _COLOR_H_
#	include "core/Color.h"
#endif

#include "sqplus/sqplus.h"
using namespace SqPlus;


class Texture : public ISmartPtr<Texture>
{
public:
	static const uint32 COLOR_TYPE_INDEX 	= 0x1900;
	static const uint32 COLOR_TYPE_ARGB 	= 0x1906;
	static const uint32 COLOR_TYPE_RGB 		= 0x1907;
	static const uint32 COLOR_TYPE_RGBA 	= 0x1908;
	static const uint32 COLOR_TYPE_GRAY 	= 0x1909;

public:
	Texture(const String& p);
	Texture(const String& p, const uint32 id, const uint32 width, const uint32 height, const uint32 rowBytes,
			const uint32 format, const uint32 scaledWidth, const uint32 scaledHeight, uint8* pixels = 0);
	virtual ~Texture();

public:
	inline const String& getPath() const { return mPath; }
	inline const uint32 getId() const { return mId; }
	inline const uint32 getWidth() const { return mWidth; }
	inline const uint32 getHeight() const { return mHeight; }
	inline const uint32 getFormat() const { return mFormat; }
	inline const uint32 getScaledWidth() const { return mScaledWidth; }
	inline const uint32 getScaledHeight() const { return mScaledHeight; }
	inline const uint32 getRowBytes() const { return mRowBytes; }

	const Color getPixelColor(const Vector2D& p);

	uint8* getPixels() const { return mPixels; }

	static void scaleTexture(const uint32 width, const uint32 height, const uint32 rowBytes, const uint32 format, const uint8* bitmap,
								const uint32 scalew, const uint32 scaleh, uint8* dest);

	void setTransparentColor(Color color);

private:
	uint32	mId;
	String 	mPath;
	uint32	mWidth;
	uint32	mHeight;
	uint32	mRowBytes;
	uint32	mFormat;
	uint32	mScaledWidth;
	uint32	mScaledHeight;
	uint8*	mPixels;
};

//must be declared here
DECLARE_INSTANCE_TYPE(Texture)

#endif /* TEXTURE_H_ */
